<script lang="ts">
  export default {
    name: 'SvgIcon',
    inheritAttrs: false,
  };
</script>
<script lang="ts" setup>
  import { computed } from 'vue';

  const props = defineProps({
    iconClass: {
      type: String,
      required: true,
    },
    className: {
      type: String,
      default: '',
    },
  });

  const iconName = computed(() => `#icon-svg/${props.iconClass}`);

  const svgClass = computed(() => {
    if (props.className) {
      return `svg-icon ${props.className}`;
    }
    return 'svg-icon';
  });
</script>

<template>
  <svg
    v-bind="$attrs"
    :class="svgClass"
    aria-hidden="true"
  >
    <use :xlink:href="iconName" />
  </svg>
</template>
<style lang="less">
.svg-icon {
  @apply w-5 h-5;
  overflow: hidden;
  vertical-align: -.15em;
  fill: currentColor;
}
</style>
